import java.util.Scanner;

public class SpiralMatrix {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[][] matrix = new int[N][N];
        int num = 1; // 起始填充数字
        int top = 0, bottom = N - 1, left = 0, right = N - 1; // 定义填充边界

        while (num <= N * N) {
            // 填充上行从左到右
            for (int i = left; i <= right; i++) {
                matrix[top][i] = num++;
            }
            top++;
            // 填充右列从上到下
            for (int i = top; i <= bottom; i++) {
                matrix[i][right] = num++;
            }
            right--;
            // 填充下行从右到左
            for (int i = right; i >= left; i--) {
                matrix[bottom][i] = num++;
            }
            bottom--;
            // 填充左列从下到上
            for (int i = bottom; i >= top; i--) {
                matrix[i][left] = num++;
            }
            left++;
        }

        // 打印螺旋方阵
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                System.out.printf("%3d", matrix[i][j]);
            }
            System.out.println();
        }
        scanner.close();
    }
}